import Department from "./components/ImportData/parseAttendanceFileToModel/Department";
import { AttendanceRecordItemModel } from "./components/ImportData/parseAttendanceFileToModel/store";

export function groupByDepartment(attendanceRecordItemModelList: AttendanceRecordItemModel[]): Map<Department, AttendanceRecordItemModel[]> {
    const map: Map<Department, AttendanceRecordItemModel[]> = new Map();
    attendanceRecordItemModelList.forEach(attendanceRecordItemModel => {
        const department = attendanceRecordItemModel.worker.department;
        let list = map.get(department);
        if (list === undefined) {
            list = [];
            map.set(department, list);
        }
        list.push(attendanceRecordItemModel);
    });
    return map;
}